package com.game.tools.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义异常
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class CustomException extends RuntimeException {

    /**
     * 状态码
     */
    private final Integer code;

    /**
     * 方法名称
     */
    private final String method;

    /**
     * 构造器
     * @param exceptionEnum 枚举对象
     * @param method 方法
     */
    public CustomException(ExceptionEnum exceptionEnum, String method){
        super(exceptionEnum.getMsg());
        this.code = exceptionEnum.getCode();
        this.method = method;
    }

    /**
     * 构造器
     * @param code 状态码
     * @param msg 错误信息
     * @param method 方法
     */
    public CustomException(Integer code, String msg, String method){
        super(msg);
        this.code = code;
        this.method = method;
    }
}
